"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Player = void 0;
const Small_1 = require("./base/Small");
const Logger_1 = __importDefault(require("../utils/Logger"));
class Player {
    constructor(gameMgr, user, pointId) {
        this.arr_bigs = new Set();
        this.num_bornBig = 0; //累计出生大子
        this.is_death = false; //是否玩家死亡
        this.gameMgr = gameMgr;
        this.user = user;
        this.username = user.username;
        this.connection = user.connection;
        this.small = new Small_1.Small(gameMgr, this, this.gameMgr.map_point.get(pointId));
        user.player = this;
    }
    gc() {
        this.gameMgr = null;
        this.user = null;
        this.connection = null;
        this.small = null;
        this.arr_bigs = null;
    }
    /** 每个类都有，将需要的数据打包放进去，会传送到客户端 */
    toObj() {
        let obj = {
            "username": this.username,
            "small": this.small.toObj(),
        };
        return obj;
    }
    /** 回合开始 */
    turnStart() {
        Logger_1.default.log(this.username, "回合开始");
        this.small.turnStart();
        this.arr_bigs.forEach(big => {
            big.turnStart();
        });
    }
    /** 回合结束 */
    turnOver() {
        Logger_1.default.log(this.username, "回合结束");
        this.small.turnOver();
        this.arr_bigs.forEach(big => {
            big.turnOver();
        });
    }
}
exports.Player = Player;
